package cn.itcast.xuesheng.service.impl;

import cn.itcast.xuesheng.dao.ShowPageDao;
import cn.itcast.xuesheng.dao.impl.ShowPageDaoImpl;
import cn.itcast.xuesheng.domain.Topic;
import cn.itcast.xuesheng.service.ShowPageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("showpageService")
public class ShowpageServiceImpl implements ShowPageService {

    @Autowired
    private ShowPageDao showPageDao;
//    public void setShowpageDao(ShowPageDaoImpl showpageDao) {
//    }
    @Override
    public Topic show(String tid) {
//        ApplicationContext applicationContext=new ClassPathXmlApplicationContext("applicationContext.xml");
//        showPageDao = applicationContext.getBean("showpageDao", ShowPageDao.class);
        return showPageDao.showPage(Integer.parseInt(tid));
    }

    @Override
    public List<Topic> findthumb() {
//        ShowPageDaoImpl showPageDao=new ShowPageDaoImpl();
//        ApplicationContext applicationContext=new ClassPathXmlApplicationContext("applicationContext.xml");
//        showPageDao = applicationContext.getBean("showpageDao", ShowPageDao.class);
        List<Topic> findthumb = showPageDao.findthumb();
        return findthumb;
    }
}
